package com.hippo.core.core.ext

import android.os.Build
import android.text.Html
import android.text.Spanned
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.intl.Locale
import androidx.compose.ui.text.toLowerCase
import com.thingclips.smart.android.common.utils.MD5


fun String.toMd5():String{
    return MD5.md5(this).toLowerCase(Locale.current)
}


fun String?.toAnnotatedString():AnnotatedString{
    val spanned: Spanned = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY)
    } else {
        Html.fromHtml(this)
    }

    val text = buildAnnotatedString {
        append(spanned)
    }
    return text
}

